{% load i18n %}
{% load core_tags %}
{% load privacy_tags %}
{% load gravatar %}
{% load projects_tags %}

{% block repo %}
  {% if project.repo %}
    <h3>{% trans "Repository" %}</h3>
    <p class="detail-long">
      {% if project.repo|slice:':4' == 'http' %}
        {{ project.repo|urlize }}
      {% else %}
        {{ project.repo }}
      {% endif %}
    </p>
  {% endif %}
{% endblock %}

{% block slug %}
  {% trans "Used in URL's and in code to represent the project name" as title %}
  <h3 title="{{ title }}">{% trans "Project Slug" %}</h3>
  <p title="{{ title }}" class="detail-long">
      {{ project.slug }}
  </p>
{% endblock %}

{% block last-built %}
  <h3>{% trans "Last Built" %}</h3>
  <p>
    {% with build=project.get_latest_build %}
      {% if build %}
          {% if build.date %}
            {{ build.date|timesince }} ago
            {% if build.success %}
              <span class="build-state build-state-passing">{% trans "passed" %}</span>
            {% else %}
              <span class="build-state build-state-failing">{% trans "failed" %}</span>
            {% endif %}
          {% else %}
            {% trans "Currently Building" %}
          {% endif %}
      {% else %}
        {% trans "No builds yet" %}
      {% endif %}
    {% endwith %}
  </p>
{% endblock %}

{% block owners %}
    <h3>{% trans "Maintainers" %}</h3>
    <p>
      {% for user in project.users.all %}
      <a href="{% url "profiles_profile_detail" user.username %}">{% gravatar user.email 32 %}</a>
      {% endfor %}
    </p>
{% endblock %}

{% block homepage %}
  {% if project.project_url %}
    <h3>{% trans "Home Page" %}</h3>
    <p>
      <a href="{{ project.project_url }}" rel="nofollow,noindex">{{ project.project_url }}</a>
    </p>
  {% endif %}
{% endblock %}

{% block badge %}
    <h3>{% trans "Badge" %}</h3>
      <img src="{{ badge_url }}" />
      <a href="{{ site_url }}" style="text-decoration: none;" onclick="$('#badge_markup').toggle(); return false;">
        <span class="badge-info" title="Get this badge"></span> 
      </a>
      {% include "core/badge_markup.html" with badge_url=badge_url site_url=site_url %}
{% endblock %}


{% block tags %}
    <h3>{% trans "Tags" %}</h3>
    <p>

    {% if project.tags.exists %}
        {% for tag in project.tags.all %}
          <a href="{% url "projects_tag_detail" tag.slug %}">{{ tag.name }}</a>{% if forloop.last %}{% else %}, {% endif %}
        {% endfor %}
    {% else %}
      {% trans "Project has no tags." %}
      {% if request.user|is_admin:project %}

        {% url 'projects_edit' project.slug as edit_url %}
          {% blocktrans trimmed %}
          Add some in your <a href="{{ edit_url }}">project settings</a>.
          {% endblocktrans %}
      {% endif %}
    {% endif %}

    </p>
{% endblock %}

{% block privacy-level %}
  <h3>{% trans "Project Privacy Level" %}</h3>
  <div id="privacy_level">
    <p>
      {{ project.get_privacy_level_display }}
    </p>
  </div>
{% endblock %}

{% block short-urls %}
  <h3>{% trans "Short URLs" %}</h3>
  <p>
    <a href="http://{{ project.slug}}.{{ PUBLIC_DOMAIN }}">{{ project.slug }}.{{ PUBLIC_DOMAIN }}</a><br>
    {% if PUBLIC_DOMAIN == "readthedocs.io" %}
    <a href="http://{{ project.slug}}.rtfd.io">{{ project.slug }}.rtfd.io</a>
    {% endif %}
  </p>
{% endblock %}

{% block translations %}
  {% if project.translations.exists %}
    <h3>{% trans "Translations" %}</h3>
      <ul>
      {% for trans in project.translations.all %}
          <li><a href="{{ trans.get_docs_url }}">{{ trans.language }}</a></li>
      {% endfor %}
      </ul>
  {% endif %}
{% endblock %}

{% block subprojects %}
  {% if project.subprojects.exists %}
    <h3>{% trans "Sub Projects" %}</h3>
      <ul>
      {% for rel in project.subprojects.all %}
          <li><a href="{{ rel.get_absolute_url }}">{{ rel.child }}</a></li>
      {% endfor %}
      </ul>
  {% endif %}
{% endblock %}

{% block defaults %}
<h3>{% trans "Default Version" %}</h3>
<p> {{ project.get_default_version }}</p>

<h3>{% trans "'latest' Version" %}</h3>
<p> {{ project.get_default_branch }}</p>
{% endblock %}
